package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.AttachVo;
import cn.ywsj.ywsjmidtier.service.WechatAttachmentFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName : WechatAttachmentController
 * @Author : Lenovo
 * @Date: 2021/7/23 15:11
 * @Description :
 */
@RestController
@RequestMapping("/wechat/attachmgr")
public class WechatAttachmentController {
    @Autowired
    private WechatAttachmentFeign wechatAttachmentFeign;
    @PutMapping("/addattach")
    public String addAttach(String uploadType, String fileType, HttpServletRequest request, AttachVo attachVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(attachVo);
        return wechatAttachmentFeign.addAttach(uploadType,fileType,request,jsonObject);
    }
    @PostMapping("/uploadimage")
    public String uploadImage(HttpServletRequest request, HttpServletResponse response) {
        return wechatAttachmentFeign.uploadImage(request,response);
    }
    @PostMapping("/uploadcredentials")
    public String uploadCredentials(HttpServletRequest request, HttpServletResponse response,AttachVo attachVo,String uploadType, String fileType){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(attachVo);
        return wechatAttachmentFeign.uploadCredentials(request,response,jsonObject,uploadType,fileType);
    }
    @PostMapping("/uploadvideo")
    public String uploadVideo(HttpServletRequest request, HttpServletResponse response, AttachVo attachVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(attachVo);
        return wechatAttachmentFeign.uploadVideo(request,response,jsonObject);
    }
}
